#ifndef BSP_ARCH_ARMV8_AARCH64_PLATFORM_UART_H
#define BSP_ARCH_ARMV8_AARCH64_PLATFORM_UART_H

#ifdef __cplusplus
extern "C"
{
#endif

#include "ft_types.h"
#include "ft_io.h"
#include "kernel.h"

#define EARLY_UART_BASE         FT_UART1_BASE_ADDR
#define EARLY_UART_IRQ_NUM      FT_UART1_IRQ_NUM
#define EARLY_UART_UARTDR       (EARLY_UART_BASE + 0x0)  /* UART 数据寄存器地址 */
#define EARLY_UART_UARTFR       (EARLY_UART_BASE + 0x18) /* UART 状态寄存器地址 */
#define EARLY_UART_UARTCR       (EARLY_UART_BASE + 0x30) 
#define EARLY_UART_UARTCR_UARTEN    BIT(0)
#define EARLY_UART_UARTCR_TXE       BIT(8)
#define EARLY_UART_UARTCR_RXE       BIT(9)
#define EARLY_UART_UARTCR_INIT  (EARLY_UART_UARTCR_UARTEN | EARLY_UART_UARTCR_TXE | \
                                 EARLY_UART_UARTCR_RXE)
#define EARLY_UART_UARTIMSC     (EARLY_UART_BASE + 0x38)
#define EARLY_UART_UARTIMSC_RXIM    BIT(4)
#define EARLY_UART_UARTIMSC_RTIM    BIT(6)
#define EARLY_UART_UARTMIS      (EARLY_UART_BASE + 0x40)
#define EARLY_UART_UARTICR      (EARLY_UART_BASE + 0x44)
#define EARLY_UART_TXFF         BIT(5)  /* 发送 FIFO 已满标志位 */
#define EARLY_UART_RXFE         BIT(4)  /* 接收 FIFO 为空标志位 */
#define EARLY_UART_DATA_MASK    GENMASK(7, 0)
#define EARLY_UART_RXI_MASK     BIT(4)

    void OutByte(s8 byte);
    char GetByte(void);
#ifdef __cplusplus
}
#endif

#endif // !